#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QtGui/QMainWindow>
#include <QtNetwork>
#include <QtSql>

#include "ndlogin.h"

namespace Ui {
	class MainWindow;
}

class MainWindow : public QMainWindow {
	Q_OBJECT
	Q_DISABLE_COPY(MainWindow)

public:
	static const QString DATETIME_FORMAT;
	static const double MAX_MONEY_MAGNITUDE;

	enum MainWidget {TABS = 0, START};
	enum Status {IDLE, LOGIN_WAIT, TRANSACTIONS_WAIT};
	enum LoginMode {LOAD, CREATE};

	explicit MainWindow(QWidget *parent = 0);
	virtual ~MainWindow();

protected:
	virtual void changeEvent(QEvent *e);

private:
	Ui::MainWindow *m_ui;
	LoginMode m_loginMode;
	QString m_filename;
	NDLogin* m_login;

	void login(const QString& netID, const QString& password);
	void showCreateDialog(const QString& = QString(), const QString& = QString());
	void loadDatabase();

	void cleanup();

private slots:
	void on_tabWidget_currentChanged(int index);
	void on_actionOpen_Account_Group_triggered();
	void on_actionNew_Account_Group_triggered();
	void on_action_Update_ND_accounts_triggered();
	void on_actionClose_Account_Group_triggered();
	void slot_loadAccountPressed();
	void slot_newAccountPressed();

	void slot_loginSuccess(const QString&);
	void slot_loginFailure();
	void slot_httpError(const QString&);
};

#endif // MAINWINDOW_H
